package com.example.learn.hwod;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class _15斗地主顺子 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] split = sc.nextLine().split(" ");
        Arrays.sort(split,(a,b)->convert(a)-convert(b));
        ArrayList<ArrayList<String>> straights = new ArrayList<>();

        for (String card : split) {
            int i = 0;
            for (; i < straights.size(); i++) {
                ArrayList<String> straight = straights.get(i);
                String pre = straight.get(straight.size() - 1);
                if (convert(card)-convert(pre)==1){
                    straight.add(card);
                    break;
                }
            }
            if (i==straights.size()) {
                ArrayList<String> straight = new ArrayList<>();
                straight.add(card);
                straights.add(straight);
            }
        }

        int count=0;
        for (ArrayList<String> straight : straights) {
            if (straight.size()<5) {
                continue;
            }
            count++;
            for (String card : straight) {
                System.out.print(card+" ");
            }
        }
        if (count==0) {
            System.out.println("No");
        }


    }

    public static int convert(String card){
        switch (card){
            case "J": return 11;
            case "Q": return 12;
            case "K": return 13;
            case "A": return 14;
            case "2": return 16;
            default: return Integer.parseInt(card);
        }
    }
}
